<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>

  <TITLE>CS631 -- Advanced Programming in the UNIX Environment</TITLE>
  <STYLE type="text/css">
  body {
  background-color: #FFFFFf;
  }
  </STYLE>
  <STYLE type="text/css">
  li.c1 {list-style: none}
  </STYLE>
</HEAD>

<BODY>
  <TABLE border="1" align="center" cellpadding="15">
    <TR>
      <TD valign="top">
        <H2>CS631 -- Advanced Programming in the UNIX Environment - Final Assignment</H2>

        <H3>Write a simple shell</H3>

<h4>Summary</h4>

<p>In this assignment you will write a simple shell.  In doing so, you
will apply most of the lessons we learned in this class and gain a better
understanding of how complex something as simple as a command-line
interpreter can become as you compare the features available in a POSIX
compliant shell with your own simple shell.</p>

<h4>Problem assignment</h4>

<p>Write a simple command-line interpreter as described in 
<a href="sish.1.pdf">this manual page</a>.  As usual, your homework
submission / program will:</p>

<p>
<ul>
<li>follow the <a href="hw">general homework guidelines</a></li>
<li>be written in plain C</li>
<li>consist of multiple files</li>
<li>include a Makefile</li>
<li>follow the principle of least surprise for the user</li>
<li>not generate any output other than that which was requested</li>
<li>generate meaningful error messages (to stderr) when appropriate</li>
</ul>
</p>

<p><em>Note</em>: You may complete this assignment individually or in a
team consisting of two people.  Either way, you should be using <a
href="git.html">git</a> and include your GitLog in your submission.  As
usual, you are free to discuss the general problem with your class mates
and discussions on the class mailing list are very much encouraged.  </p>

<h4>Hints</h4>

<p>Given the number of aspects covered in this assignment, I would suggest
that you try to implement features incrementally in the following
order:</p>

<h5>Shell startup, options parsing, command parsing / tokenization</h5>

<p>Begin by implementing the standard <tt>getopt(3)</tt> flow, initialize
your world, print a command-line prompt and read input from the
controlling terminal.</p>

<p>Split the given string into tokens.</p>

<p>Make sure your shell can't be terminated by <tt>Ctrl+C</tt>, and can be
exited successfully.</p>

<h5>Builtins</h5>

<p>Implement all listed builtins with all supported arguments / exit
status.  Resist the temptation to implement additional features not
requested in the assignment.</p>

<h5>Fork-exec commands</h5>

<p>Create a new process and execute commands.  Wait for them to complete.
Make their exit status available.</p>

<h5>Implement I/O Redirection</h5>

<p>Inspect the list of tokens for supported I/O redirection operators.
Ensure no illegal combination is given.  Implement the correct
redirection.  Make sure to handle error cases correctly and report
meaningful errors to the user.</p>

<h5>Implement pipelines</h5>

<p>Split the input by the pipe operator before tokenization.  Fork new
processes for each command in the pipe, connect stdout/stdin as needed.
Execute the commands.</p>

<h5>Implement backgrounding of processes</h5>

<p>Only implement placing commands into the background after all other
functionality is present.</p>

<h4>Deliverables and Due Date</H4>

<p>You will submit a single tar archive named <em>username</em>-sish.tar
that will extract into a directory named after your username. In that
directory will be all your files together with a <tt>Makefile</tt>. If you
have any commentary on your submission, include it in a file called
<tt>README</tt>.</p>

<p> The due date for this assignment is 2014-12-18 18:00. Please attach
the file to an email sent from your <tt>@stevens.edu</tt> email address to
<a href="mailto:jschauma@stevens.edu?subject=[CS631]
sish">jschauma@stevens.edu</a> with a subject of "[CS631] sish".</p>

        <hr>
        [<a href="index.html">Course Website</a>]
</BODY>
</HTML>
